<!--
 * @Author: [kangjie]
 * @Date: 2022-03-30 10:49:39
 * @LastEditors: [kangjie]
 * @LastEditTime: 2022-03-30 15:07:54
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>
<body>
  <div id="app">
    {{typeof a}}
    a:<input type="text" v-model.number="a">
    <br>
    +
    <br>
    b:<input type="text" v-model.number="b">
    <br>
    =
    <output>{{total}}</output>
  </div>
  <script>
    new Vue({
      el:'#app',
      data:{
        // 监听的是基本数据类型
        a:0,
        b:0,
        total:0
      },
      // 监听器 监听属性的变化
      watch:{
        a(newValue,oldValue){
          // console.log(newValue,oldValue);
          this.total=this.a+this.b;
        },
        b(newValue,oldValue){
          // console.log(newValue,oldValue);
          this.total=this.b+this.a;
        }
      },
      methods:{
        
      }
    })
  </script>
</body>
</html>